package linter.custom;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author 爻
 */
@Component
public class Constant {
    /**
     * 1.Token 常量
     */
    public static int ACCESS_TOKEN_ACTIVE;
    public static int REFRESH_TOKEN_ACTIVE;
    @Value("${constant.token.accessTokenActive}")
    public void setAccessTokenActive(int accessTokenActive) {
        ACCESS_TOKEN_ACTIVE = accessTokenActive;
    }
    @Value("${constant.token.refreshTokenActive}")
    public void setRefreshTokenActive(int refreshTokenActive) {
        REFRESH_TOKEN_ACTIVE = refreshTokenActive;
    }

    /**
     * 2.响应状态 常量
     */
    public static final int RES_FAIL = 400;
    public static final int RES_SUCCESS = 200;
    public static final int RES_ERROR = 500;

    /**
     * 3.加密 常量
     */
    public static int  PWD_HASH_ITERATIONS;
    public static int  JWT_HASH_ITERATIONS;
    @Value("${constant.hashIterations.pwd}")
    public void setPwdHashIterations(int pwdHashIterations) {
        Constant.PWD_HASH_ITERATIONS = pwdHashIterations;
    }
    @Value("${constant.hashIterations.jwt}")
    public void setJwtHashIterations(int jwtHashIterations) {
        Constant.JWT_HASH_ITERATIONS = jwtHashIterations;
    }

    /**
     * 4.缓存 相关
     */
    public static int REDIS_INDEX_SERVICE;
    public static int REDIS_INDEX_UTILS;
    @Value("${constant.redis.serviceIndex}")
    public void setRedisIndexService(int redisIndexService) {
        REDIS_INDEX_SERVICE = redisIndexService;
    }
    @Value("${constant.redis.utilsIndex}")
    public void setRedisIndexUtils(int redisIndexUtils) {
        REDIS_INDEX_UTILS = redisIndexUtils;
    }

    /**
     * 5.权限/常量字段 相关
     */
    public static final String ROLE_RANK_2 = "user";
    public static final String ROLE_RANK_1 = "editor";
    public static final String ROLE_RANK_0 = "admin";
    public static final String POWER_CODE = "POWER_CODE";
    public static final String BLOG_VIEWS_NAME = "MAP_BLOG_VIEWS";


    /**
     * 8、条件查询依据常量
     */
    public static Integer DESC_VALUE=2;
    public static Integer DEFAULT_VALUE=0;
    public static Integer SECOND_BASIS_VALUE = 2;

    /**
     * 9、业务数据缓存时间
     */
    public static int CACHE_TIME_ONE_DAY=86400;
    /**
     * string转换方法
     * @param obj 对象
     * @return 字符串
     */
    public static String valueOf(Object obj) {
        return (obj == null) ? null : obj.toString();
    }

    /**
     * 默认用户头像
     */
    public static String DEFAULT_IMG_URL_ICON = "https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png";

    /**
     * 默认封面
     */
    public static String DEFAULT_IMG_URL_NOTE = "http://qiniuyun.linter.top/Linter/Vue_img/Note/%E7%AC%94%E8%AE%B0%E5%B0%81%E9%9D%A2.png";

    /**
     * 用户默认名称
     */
    public static String DEFAULT_USER_NAME = "默认名称";

    /**
     * 用户默认性别 0：未知，1：男，2：女
     */
    public static Integer DEFAULT_USER_SEX = 0;

    /**
     * 用户默认简介
     */
    public static String DEFAULT_USER_SIGNATURE = "默认简介";

    /**
     * 笔记默认标题
     */
    public static String DEFAULT_NOTE_TITLE = "默认标题";

    /**
     * 笔记常量初始值默认
     */
    public static Integer NOTE_CONSTANT_INITIAL_VALUE_DEFAULT = 0;

    /**
     * 腾讯云登录 API
     */
    public static String  smsSign  = "linter学习笔记网";
    public static int loginId  = 2095955;
    public static int RegisterId =  2095956;
    public  static   String SmsAapKey = "07c0de57cc2e2c617745621ae96070a6";
    public  static  int SmsAppid = 1400896037;

    /**
     * 七牛云API
     */
    public static String ACCESS_KEY_QINIU = "CKAWgGNUtJB1TFofmKtQ9nqfvqDS6lQdKkAiHh04";
    public static String SECRET_KEY_QINIU = "ttBa1dX8s9aoYbzqjGf6Sn63ErZYikWo1ELHsbuQ";
    public static String BUCKET_NAME_QINIU = "linter-beiyu";

    /**
     * 模型种类
     */
    public static Integer LINEAR = 1;
    public static Integer LOGISTIC_REGRESSION = 2;
}
